package net.looker.monitor.checker;

import java.util.Iterator;

import net.looker.data.News;
import net.looker.monitor.modifier.AddModifier;
import net.looker.monitor.modifier.DispatcherManager;
import net.looker.monitor.schdule.NewsManager;



/**
 * 新增新闻检查器
 * @author solosky
 *
 */

public class AddChecker extends Checker
{
	
	public AddChecker(NewsManager newManager) 
	{
		super(newManager);
	}

	@Override
	public void check()
	{
		//得到最新新闻列表迭代对象
		Iterator<News> it = newsManager.getCurNewsList().iterator();
		//遍历所有的最新新闻
		News curNews = null;
		News lastNews = null;
		
		while (it.hasNext())
		{
			curNews = it.next();
			lastNews = newsManager.getLastNews(curNews.getNewsHash());
			
			//如果在上一次新闻没有找到，则是最新新闻
			if (lastNews==null)
			{
				//Logger.getLogger("looker").info("新增新闻："+curNews.toString());
				DispatcherManager.add(new AddModifier(curNews));
			}
		}
		
	}

}
